/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dsproject;

import java.io.Serializable;

/**
 *
 * @author jkf2
 */
public class Sending implements Serializable{

    int TTL;
    Node node;

    //Used for comparison
    public Sending(Node node) {
        this.node = node;
    }

    public Sending(Node node, int TTL) {
        this.node = node;
        this.TTL = TTL;
    }

    public Node getNode() {
        return node;
    }

    public boolean isValid(int atTime) {
        return TTL > atTime;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Sending other = (Sending) obj;
        if (this.node != other.node && (this.node == null || !this.node.equals(other.node))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 29 * hash + (this.node != null ? this.node.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString(){
        return this.node.toString();
    }
}
